package controller;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.doa.Doa;
import com.doa.DoaPerson;
import com.doa.beans.Person;

import com.opensymphony.xwork2.ActionSupport;

public class CreateController extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Person personBean;
	
	public Person getPersonBean() {
		return personBean;
	}

	public void setPersonBean(Person personBean) {
		this.personBean = personBean;
	}

	public String execute(){
		String path = ServletActionContext.getServletContext().getRealPath("/");
		Doa doaPerson = DoaPerson.getInstance();
		doaPerson.setPath(path);
		doaPerson.create(getPersonBean());
		HttpServletRequest request = ServletActionContext.getRequest();
		request.setAttribute("msg", "person info saved");
		return "success";
	}

}
